From 46466176e203edb6700f00b731ef9d8352bbbb5f Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Thu, 1 Jun 2006 05:19:16 +0000 Subject: [PATCH] add docs --- ChangeLog | 2 ++ ChangeLog.pre-2-10 | 2 ++ gtk/gtkprintoperation.c | 72 +++++++++++++++++++++++++++++++++++++++-- 3 files changed, 74 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index a1578e3764..1b1ce4334f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,7 @@ 2006-06-01 Matthias Clasen + * gtk/gtkprintoperation.c: Add some examples to the docs. + * gtk/gtkprintbackend.c (gtk_print_backend_class_init): Intern signal names. diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index a1578e3764..1b1ce4334f 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,5 +1,7 @@ 2006-06-01 Matthias Clasen + * gtk/gtkprintoperation.c: Add some examples to the docs. + * gtk/gtkprintbackend.c (gtk_print_backend_class_init): Intern signal names. diff --git a/gtk/gtkprintoperation.c b/gtk/gtkprintoperation.c index b568c94d4a..64781ebcca 100644 --- a/gtk/gtkprintoperation.c +++ b/gtk/gtkprintoperation.c @@ -379,7 +379,44 @@ gtk_print_operation_class_init (GtkPrintOperationClass *class) * from @context using gtk_print_context_get_cairo_context(). * * - * FIXME: need an example here + * static void + * draw_page (GtkPrintOperation *operation, + * GtkPrintContext *context, + * gint page_nr, + * gpointer user_data) + * { + * cairo_t *cr; + * PangoLayout *layout; + * gdouble width, text_height; + * gint layout_height; + * PangoFontDescription *desc; + * + * cr = gtk_print_context_get_cairo_context (context); + * width = gtk_print_context_get_width (context); + * + * cairo_rectangle (cr, 0, 0, width, HEADER_HEIGHT); + * + * cairo_set_source_rgb (cr, 0.8, 0.8, 0.8); + * cairo_fill (cr); + * + * layout = gtk_print_context_create_pango_layout (context); + * + * desc = pango_font_description_from_string ("sans 14"); + * pango_layout_set_font_description (layout, desc); + * pango_font_description_free (desc); + * + * pango_layout_set_text (layout, "some text", -1); + * pango_layout_set_width (layout, width); + * pango_layout_set_alignment (layout, PANGO_ALIGN_CENTER); + * + * pango_layout_get_size (layout, NULL, &layout_height); + * text_height = (gdouble)layout_height / PANGO_SCALE; + * + * cairo_move_to (cr, width / 2, (HEADER_HEIGHT - text_height) / 2); + * pango_cairo_show_layout (cr, layout); + * + * g_object_unref (layout); + * } * * * Use gtk_print_operation_set_use_full_page() and @@ -1856,7 +1893,38 @@ print_pages (GtkPrintOperation *op, * See gtk_print_operation_run_async() if this is a problem. * * - * FIXME: need an example here + * if (settings != NULL) + * gtk_print_operation_set_print_settings (print, settings); + * + * if (page_setup != NULL) + * gtk_print_operation_set_default_page_setup (print, page_setup); + * + * g_signal_connect (print, "begin-print", + * G_CALLBACK (begin_print), &data); + * g_signal_connect (print, "draw-page", + * G_CALLBACK (draw_page), &data); + * + * res = gtk_print_operation_run (print, parent, &error); + * + * if (res == GTK_PRINT_OPERATION_RESULT_ERROR) + * { + * error_dialog = gtk_message_dialog_new (GTK_WINDOW (parent), + * GTK_DIALOG_DESTROY_WITH_PARENT, + * GTK_MESSAGE_ERROR, + * GTK_BUTTONS_CLOSE, + * "Error printing file:\n%s", + * error->message); + * g_signal_connect (error_dialog, "response", + * G_CALLBACK (gtk_widget_destroy), NULL); + * gtk_widget_show (error_dialog); + * g_error_free (error); + * } + * else if (res == GTK_PRINT_OPERATION_RESULT_APPLY) + * { + * if (settings != NULL) + * g_object_unref (settings); + * settings = g_object_ref (gtk_print_operation_get_print_settings (print)); + * } * * * Return value: the result of the print operation. A return value of -- 2.30.2